#include<bits/stdc++.h>
using namespace std;
int a[100005];
bool aa[100005];
int n;
int maxn;
void fun()
{
    int c = 0;
    for(int i = 2; i <= n; i++)
    {
        for(int j = i - 1; j >= 1; j--)
        {
            if(aa[j] == aa[i]&&a[j]==a[i])
            {
                c = c +a[i];
                continue;
            }
        }
    }
    maxn = max(maxn,c);
}
int dg(int k)
{
    if(k > n)
    {
        fun();
        return 0;
    }
    aa[k] = 1;
    dg(k+1);
    aa[k] = 0;
    dg(k+1);
}
void work()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    dg(1);
}
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int t;
    cin >> t;
    for(int i = 1; i <= t; i++)
    {
        maxn=-1000;
        work();
        cout << maxn << "\n";
    }
    return 0;
}
